package com.ycw.servlet.wangwang;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.ContractDao;
import com.ycw.dao.impl.ContractDaoImpl;
import com.ycw.pojo.Contract;

@WebServlet("/doDeleteServlet")
public class doDeleteContractByIdServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String c_id = request.getParameter("c_id");
		int scno = Integer.parseInt(c_id);
		Contract contract = new Contract();
		contract.setC_id(scno);
		ContractDao cd = new ContractDaoImpl();
		int i = cd.contractDelete(contract);
		boolean f = false;
		if (i > 0) {
			f = true;
		}
		// 向前端发送JSON数据
		String resJSON = JSON.toJSONString(f);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();
	}
}
